$(document).ready( function() {
	
	$('#contratoid').autotab({nospace:true, format:'numeric'});	

	$('#contratoid').blur( function () {
	fieldName = $(this).attr('id');
	fieldValue = $(this).val();
	$.post('/cake/syscable/MgDescuentos/ajax_validate', {
	                                field: fieldName,
	                                value: fieldValue
	                                },
	       function(error) {                                                                	                                        	
	           if(error.length != 0) {                
	        		if($('#' + fieldName + '-exists').length == 1){
	            		$('#' + emailField + '-exists').remove();
	            		}
	               $('#contratoid').after('<div class="error-message" id="'+ fieldName +'-exists">' + error + '</div>');
	               $('#contratoid').addClass('form-error');
	           }
	           else {
	               $('#' + fieldName + '-exists').remove();
	               $('#contratoid').removeClass('form-error');
	               $('#contratoid').addClass('reqaceptado');
	           }
	       })
	});
});